package module4;
import java.awt.*;
import java.net.*;
import jvav.io.*;

	//this is the lab template
	//fill in the code for the two methods called from main
class ReadFile 
{
	//This method will send the file name to read to the 
	//server. You need to set up your own data output
	//stream to pass the filename to the server(which
	//should be rendering a data input stream and expecting a string).
	
	public static void sendFileName(Socket s, String fileName) throws IOException
	{
		//Fill in this method - hint: create a stream to 
		//send the fileName to the server
	}
	
	//this method will receive the file from the server, 
	//or the result of the attempt to read the file.
	
	public static void receiveFile(Socket s) throws IOException
	{
		//Fill in this method
	} 
	public static void main(String[] args) 
	{
		Socket s;
		int port = 5151;
		
		//did we receive the correct number of arguments?
		if(args.length != 2)
		{
			System.out.println("Usage: java readFile <server> <file>");
			System.exit(-1);
		}
		
		try
		{
			//open our connection to args[0]
			s = new Socket(args[0], port);
			
			//send the file name to the server
			sendFileName(s, args[1]);
			
			//output the file(or result of the request)
			receiveFile(s);
			
			//when the eof is reached, just close the connection and exit
			s.close();
		}
		catch(IOException ioe)
		{
			//ignore
		}
	}	
}

